package com.kclmedu.ribbon;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/*********
 * @Author yejf
 * @Description Spring Boot的启动类，负责加载Spring boot的内置配置
 * @Date 22:11 2019-12-01
 * @param
 * @return
 */
@SpringBootApplication //以 springboot方式启动
@EnableEurekaClient //以Eureka client方式启动
@EnableDiscoveryClient  //向服务中心注册
@EnableHystrix  //启动 断路器 【前提：要在pom.xml中导入 spring-cloud-starter-netflix-hystrix 依赖】
public class ServiceRibbonApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceRibbonApplication.class, args);
    }

    @Bean //注册到上下文中
    @LoadBalanced  //启动负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
